public String GPrinter(Map<String, Object> params){
    try {
        int maxMaterialLength = 13; //物料名称占位长度（中文）
        int maxCountLength = 8;//重量占位长度（数字）
        int maxUnitLength = 2;//最大单位长度
        //数据列
        ArrayList tableList = (ArrayList) params.get("tableData");
        //第一行表头空格计算
        StringBuffer FMSpace = new StringBuffer();
        for (int w = 0; w < maxMaterialLength-2; w++) {
            FMSpace.append("\u3000"); // 表头品名后面添加的空格占位符
        }
        StringBuffer FCSpace = new StringBuffer();
        for (int e = 0; e < maxCountLength-4; e++) {
            FCSpace.append(" "); // 表头品名后面添加的空格占位符
        }
        //客户
        String purchaseUnitsName = params.get("purchaseUnitsName").toString();
        //日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = sdf.format(new Date());//日期
        System.setProperty("jna.encoding", "GBK");
        TscLibDll.INSTANCE.openport("GP-D801 Series");
        //切纸,加粗，字号：中,凤鸣
//            TscLibDll.INSTANCE.sendBinaryData(Command.RESET.getCommandBytes(),Command.RESET.getCommandBytes().length);
        TscLibDll.INSTANCE.sendBinaryData(Command.ALINE_CENTER.getCommandBytes(),Command.ALINE_CENTER.getCommandBytes().length);
        TscLibDll.INSTANCE.sendcommand("***********销售出库小票***********");
        TscLibDll.INSTANCE.sendcommand("客户："+purchaseUnitsName+"");
        TscLibDll.INSTANCE.sendcommand("日期："+dateString+"");
        TscLibDll.INSTANCE.sendBinaryData(Command.toLarge2.getCommandBytes(),Command.toLarge2.getCommandBytes().length);
        TscLibDll.INSTANCE.sendBinaryData(Command.toLarge.getCommandBytes(), Command.toLarge.getCommandBytes().length);
        TscLibDll.INSTANCE.sendcommand("--------------------------------");
        StringBuffer nameDetail = new StringBuffer();
        nameDetail.append("品名"+FMSpace+"数量"+FCSpace+"单位");
        TscLibDll.INSTANCE.sendcommand(nameDetail.toString());
        StringBuffer detail = new StringBuffer();
        for(int i=0; i< tableList.size(); i++){
            HashMap map = (HashMap)tableList.get(i);
            String materialName = map.get("material").toString();//物料名称
            detail.append(materialName);
            if(materialName.contains("(")){
                for (int r = 0; r < maxMaterialLength-materialName.length()-1; r++) {
                    detail.append("\u3000"); // 表头品名后面添加的空格占位符
                }
            }else{
                for (int r = 0; r < maxMaterialLength-materialName.length(); r++) {
                    detail.append("\u3000"); // 表头品名后面添加的空格占位符
                }
            }
            BigDecimal count = new BigDecimal(map.get("weight").toString());//填写的数量
            detail.append(count.toString());
            for (int u = 0; u < 8-count.precision(); u++) {
                detail.append(" "); // 添加相同数量的空格
            }
            String unit = map.get("unit").toString();//单位
            for (int t = 0; t < maxUnitLength-unit.length(); t++) {
                detail.append("\u3000"); // 添加相同数量的空格
            }
            detail.append(unit + "\n");
        }
        TscLibDll.INSTANCE.sendcommand(detail.toString());
        TscLibDll.INSTANCE.sendcommand("--------------------------------");
        TscLibDll.INSTANCE.sendcommand("");
        TscLibDll.INSTANCE.sendcommand("");
        TscLibDll.INSTANCE.sendcommand("");
        TscLibDll.INSTANCE.sendcommand("");
        TscLibDll.INSTANCE.sendBinaryData(Command.CUT_PAPER.getCommandBytes(), Command.CUT_PAPER.getCommandBytes().length);
//            TscLibDll.INSTANCE.sendBinaryData(Command.BUZZING.getCommandBytes(), Command.BUZZING.getCommandBytes().length);
//            TscLibDll.INSTANCE.clearbuffer();
        TscLibDll.INSTANCE.closeport();
        return "出库完毕,打印成功";
    } catch (Exception e) {
        return e.getMessage();
    }
}

